#include "student_1.h"
#include "ui_student_1.h"
#include"student.h"
#include"execsql.h"
#include"studentinfo.h"

#include <QSqlQueryModel>
#include<QMessageBox>
#include<QDebug>

Student_1::Student_1(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Student_1)
{
    ui->setupUi(this);
}

Student_1::~Student_1()
{
    delete ui;
}

void Student_1::selectBoxSlot(QString id)//查询箱子状态
{
    bool ok = connectsqliteA.ok;
    if(ok)
    {
        QSqlQueryModel *model = new QSqlQueryModel(ui->tableView_A);

        model->setQuery(QString("select * from AdmintorInfoTable where ID = '%1';").arg(id));
        //列名
        model->setHeaderData(0, Qt::Horizontal, tr("ID"));
        model->setHeaderData(1, Qt::Horizontal, tr("Name"));
        model->setHeaderData(2, Qt::Horizontal, tr("Sex"));
        model->setHeaderData(3, Qt::Horizontal, tr("Birth"));
        model->setHeaderData(4, Qt::Horizontal, tr("loginpw"));
        model->setHeaderData(5, Qt::Horizontal, tr("face"));

        ui->tableView_A->setModel(model);//数据放置进去
        ui->tableView_A->verticalHeader()->hide();//不显示序号
    }
    else
    {
        QMessageBox::warning(this,"错误","未连接，请检查.");
    }
}

void Student_1::slotformsclass()
{
    formssclassW->show();
    formssclassW->str = str;
}

 void Student_1::showstudent_1()
 {
     emit signalstudent_1();
     this->show();
 }

 void Student_1::showSW()
 {
     Student *tw = new Student;
     tw->show();
     tw->selectBoxSlot(str);
 }

void Student_1::on_pb_rememberface_clicked()
{
    this->hide();
    this->showSW();
}

void Student_1::on_pushButton_clicked()
{
    formssclassW = new FormSclass;
    connect(formssclassW,&FormSclass::signalformSclass,this,&Student_1::slotformsclass);
    this->hide();
    formssclassW->showformSclassW();
}

void Student_1::on_commandLinkButton_clicked()
{
    this->hide();
    this->showSW();
}
